#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int getLongest(string& s1, string& s2)
{
    if (s1.size() > s2.size())
    {
        swap(s1, s2);
    }
    int n = s1.size();
    int m = s2.size();
    vector<vector<int>> vv(n + 1, vector<int>(m + 1, 0));
    int max_size = 0;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= m; ++j)
        {
            if (s1[i - 1] == s2[j - 1])
                vv[i][j] = vv[i - 1][j - 1] + 1;
            max_size = max(max_size, vv[i][j]);
        }
    }
    return max_size;
}
int main() {
    string s1, s2;
    while (cin >> s1 >> s2)
    {
        cout << getLongest(s1, s2) << endl;
    }
    return 0;
}